﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ExcelToOracle
{
    public partial class SelectSheetDialog : Form
    {
        public string SelectedSheet { get; set; }

        public SelectSheetDialog(List<string> sheets)
        {
            InitializeComponent();

            foreach(string sheet in sheets)
            {
                _listSheet.Items.Add(sheet);
            }
        }

        private void _btnSelect_Click(object sender, EventArgs e)
        {
            if (_listSheet.SelectedItem == null)
            {
                MessageBox.Show(
                    "选择Sheet",
                    "提示",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning);
                return;
            }

            if (MessageBox.Show(
                "选择Sheet" + (string)_listSheet.SelectedItem + "?",
                "提示",
                MessageBoxButtons.OK,
                MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK)
            {
                SelectedSheet = (string)_listSheet.SelectedItem;
                DialogResult = System.Windows.Forms.DialogResult.OK;
            }
        }

        private void _listSheet_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (_listSheet.SelectedItem != null)
            {
                if (MessageBox.Show(
                    "选择Sheet [" + (string)_listSheet.SelectedItem + "]?",
                    "提示",
                    MessageBoxButtons.OKCancel,
                    MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK)
                {
                    SelectedSheet = (string)_listSheet.SelectedItem;
                    DialogResult = System.Windows.Forms.DialogResult.OK;
                }
            }
        }
    }
}
